/**
 *  @file FileSys.h
 */
#ifndef _FILESYS_H_
#define _FILESYS_H_

#include "../common/BaseObject.h"
#include "../text/CFString.h"
#include "../collections/ListT.h"
#include "../util/DateTime.h"

namespace cppflib
{

namespace os
{

_DLLAPI bool DelFile(pcwstr_t filePath);
_DLLAPI bool CpFile(pcwstr_t orgFile, pcwstr_t newFile, bool failIfExists);
_DLLAPI bool MvFile(pcwstr_t orgFile, pcwstr_t newFile, bool failIfExists);
_DLLAPI bool MakeDirectory(pcwstr_t pathName, bool createIntermediateDirs);
_DLLAPI bool DelDirectory(pcwstr_t pathName);
_DLLAPI void GetCurDirectory(CFString &path);
_DLLAPI bool ChangeDirectory(pcwstr_t pathName);

_DLLAPI u64_t GetFileSize(pcwstr_t filePath);
_DLLAPI bool FileExists(pcwstr_t filePath);

/**
 *  A representation of a file system entity identified by a path name
 */
class _DLLAPI File : public BaseObject
{
public:
   /* constants for separators */
   PUBLIC const pcwstr_t PathSeparator;
   PUBLIC const wc_t PathSeparatorChar;
   PUBLIC const pcwstr_t DirSeparator;
   PUBLIC const wc_t DirSeparatorChar;

private:
   CFString fullFilePath;

private:
   File(void);
   explicit File(pcwstr_t fullPath);
   explicit File(const char * fullPath);

public:
   virtual ~File(void);
   bool CanExecute();
   bool CanRead();
   bool CanWrite();
   bool Exists();
   bool IsDir();
   bool IsFile();
   bool IsHidden();

   util::DateTime GetCreationTime();
   util::DateTime GetLastModifiedTime();
   u64_t GetSize();
   void GetAbsolutePath(CFString &path);
   void GetName(CFString &fileName);
   void GetParent(CFString &parentPath);

   collections::ListCppObjT<CFString> * GetChildFileNames();
   collections::ListCppObjT<File> * GetChildFiles();
 
   PUBLIC File * GetInstance(pcwstr_t filePath);
};

} // end of namespace os

} // end of namespace cppflib

#endif
